//
//  TableViewCell.m
//  NEWS
//
//  Created by lanou on 16/4/6.
//  Copyright © 2016年 孙金龙. All rights reserved.
//

#import "TableViewCell.h"
#import "UIImageView+WebCache.h"
#define KWidth [UIScreen mainScreen].bounds.size.width
#define KHeight  [UIScreen mainScreen].bounds.size.height
@implementation TableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _imageview = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 80, 80)];
        _imageview.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_imageview];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 15, KWidth-95, 50)];
        _titleLabel.numberOfLines = 0;
        _titleLabel.font = [UIFont systemFontOfSize:14];
        //_titleLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_titleLabel];
        
        _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(KWidth*4/5, 65, 100, 25)];
        _commentLabel.font = [UIFont systemFontOfSize:12];
        //_commentLabel.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_commentLabel];
        
        _sourceLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 65, 150, 35)];
        //_sourceLabel.textColor = [UIColor lightGrayColor];
        _sourceLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_sourceLabel];
        
        
    }
    return self;
}

// set model方法
- (void)setModel:(TableViewModel *)model
{
    _model = model;
    [_imageview sd_setImageWithURL:[NSURL URLWithString:model.thumbnail]];
    _titleLabel.text = model.title;
    if (model.comments == nil)
    {
        model.comments = @"0";
    }
    _commentLabel.text = [NSString stringWithFormat:@"评论: %@",model.comments];
    
    _sourceLabel.text = model.source;
    
    if (model.images.count !=0)
    {
            }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
